'In form code module, copy/paste the following code

Declare Sub mciSendStringA Lib "winmm.dll" (ByVal lpstrCommand As String, _
ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, _
ByVal hWndCallback As Long)

Private Sub Form_Activate()
    
    mciSendStringA "Set CDAudio Door Open", 0&, 0, 0

End Sub

Private Sub Form_Close()

    mciSendStringA "Set CDAudio Door Closed", 0&, 0, 0

End Sub